#include <stdio.h>

void printProgressBar(int progress, int total, int barWidth) {
    float percentage = (float)progress / total;
    int filledWidth = barWidth * percentage;

    printf("[");
    for (int i = 0; i < barWidth; i++) {
        if (i < filledWidth) {
            printf("=");
        } else {
            printf(" ");
        }
    }
    printf("] %.2f%%\r", percentage * 100);
    fflush(stdout);
}

int main() {
    int total = 100;
    for (int i = 0; i <= total; i++) {
        printProgressBar(i, total, 50);
        // 模拟一些工作的延迟
        for (int j = 0; j < 10000000; j++) {
            // 延迟
        }
    }
    printf("\n");

    return 0;
}

